<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<html>
<head>
	<title>标签管理</title>
	<link rel="stylesheet" href="${ctx}/static/uploadify/uploadify.css" />
	<script src="${ctx}/static/uploadify/jquery.uploadify.min.js" type="text/javascript"></script>
	<style type="text/css">
		#previewImgs{
	        width:150px;
	        height:100px;
	        list-style:none;
        }
        #previewImgs li{
	         max-width:350px;
	         height:auto;
	         float:left;
	         margin:3px;
         }
	</style>
</head>

<body>

	<div class="main-content-inner">
		<div class="breadcrumbs" id="breadcrumbs">
			<script type="text/javascript">
				try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
			</script>
			<ul class="breadcrumb">
				<li>
					<i class="ace-icon fa fa-home home-icon"></i>
					<a href="${ctx}/welcome">主页</a>
				</li>
				<li class="active">标签</li>
			</ul>
		</div>	
		
		<div class="page-content">
			
			<c:if test="${not empty message}">
				<div id="message" class="alert alert-success"><button data-dismiss="alert" class="close">×</button>${message}</div>
			</c:if>	
			
			<div class="page-header">
				<h1>
					价格
					<small>
						<i class="ace-icon fa fa-angle-double-right"></i>
						<c:if test="${action eq 'create'}">新增</c:if>
						<c:if test="${action eq 'update'}">修改</c:if>标签
					</small>
				</h1>
			</div>		
			
			<div class="row">
				<div class="col-xs-12">
					<!-- PAGE CONTENT BEGINS -->
					<div class="row">
						<div class="col-xs-12">

							<form id="inputForm" action="${ctx}/feedtag/${action}" method="post" class="form-horizontal">
								<input type="hidden" name="id" id="id" value="${feedtag.id}"/>
								<input type="hidden" name="op" id="op" value="${action}"/>
								<div class="form-group">
									<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 名称: </label>
									<div class="col-sm-9">
										<input type="text" class="col-xs-10 col-sm-2 required"  maxlength="30" autocomplete="off" id="name"  name="name"  value="${feedtag.name}" placeholder="标签名称"/>
									</div>
								</div>
								
								<div class="form-group">
									<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 排序: </label>
									<div class="col-sm-9">
										<input type="text" class="col-xs-10 col-sm-2 required"  autocomplete="off" id="seq"  name="seq"  value="${feedtag.seq}" placeholder="排序" />
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-3 control-label no-padding-right" for="form-field-1">状态: </label>
									<div class="col-sm-2">
										<select class="chosen-select form-control" id="state" name="state" data-placeholder="">
											  <option value="1" <c:if test="${feedtag.state eq '1' }">selected="selected"</c:if>>创建</option>
											  <option value="2" <c:if test="${feedtag.state eq '2' }">selected="selected"</c:if>>使用</option>
											  <option value="3" <c:if test="${feedtag.state eq '3' }">selected="selected"</c:if>>下架</option>
										</select>
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-3 control-label no-padding-right" for="form-field-1">备注: </label>
									<div class="col-sm-9">
										<textarea id="descp" name="descp"  class="col-xs-10 col-sm-5" rows="5">${feedtag.descp}</textarea>
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-3 control-label no-padding-right" for="form-field-1">照片内容: </label>
									<div class="col-sm-9">
										<input id="upload_pact_file" name="upload_pact_file" type="file" class="wjyy" />
									</div>
								</div>
								<div class="preview" style="margin-left:23%">
									<input id="pic" name="pic" type="hidden"> 
									<ul id="previewImgs">
										<li><img id="picimg" src="${feedtag.pic}" width="120" height="80" ></li>
									</ul>
								</div>
								<div class="clearfix form-actions">
									<div class="col-md-offset-3 col-md-9">
										<button id="submit_btn" class="btn btn-info" type="submit">
											<i class="ace-icon fa fa-check bigger-110"></i>
											提交
										</button>

										&nbsp; &nbsp; &nbsp;
										<button id="cancel_btn" class="btn" type="reset" onclick="history.back()">
											<i class="ace-icon fa fa-undo bigger-110"></i>
											返回
										</button>
									</div>
							  </div>
								
							</form>
							
						</div>
					</div>			
				</div>
			</div>
			
		</div>
	</div>

	<script src="${ctx}/static/js/jquery.validate.min.js"></script>
	<script src="${ctx}/static/js/messages_bs_zh.js"></script>

	<script>
		$(document).ready(function() {
			$("#title").focus();
			$("#inputForm").validate({
				rules:{
					title:{
						maxlength:150,
						minlength:1,
						remote: "${ctx}/feedtag/ajaxcheck?op="+$('#op').val()+"&id="+$('#id').val()
					},
					seq:{
						number:true,
						min:1
					}
					
				},
				messages: {
					title: {
						remote: "名称已存在"
					}
				}
			});
		});
		
		$('#upload_pact_file').uploadify({
		 	'queueID'  : 'some_file_queue',
			'buttonText' : '上传图片', 
			'swf'      : '${ctx}/static/uploadify/uploadify.swf',
			'uploader' : '${ctx}/ajax/fileUpload?type=3&id=1',
			'fileSizeLimit':'5MB', 
			'fileObjName'   : 'file',  
			'fileTypeExts'  : '*.jpg;*.jpeg;*.gif;*.png',
			'fileDesc': '请选择png,jpg,jpeg,gif等文件格式',
			'removeCompleted'	: false,
			'width' : 100, 
            'removeCompleted':false,
			'buttonClass'	: "btn btn-info",
		    'onUploadSuccess' : function(file, data, response) {  
		        console.log(data);
		        if(data!=""){					
			        $('#picimg').attr("src", data);  
			        document.getElementById("pic").value=data;
				}

		    } ,
		    'onCancel':function(file){
		    	alert("取消上传");
		    },
		    'onInit': function () {
		        $("#file_upload-queue").hide();
		    }
		}); 
	</script>
</body>
</html>
